{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Operators ??\n",
    "\n",
    "- operators operate on operands \n",
    "\n",
    "\n",
    "# Comparison operators ?\n",
    "\n",
    "- When we want to compare two operands with some action we use comparison operators "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 1 #( = means equal to )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "b = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a == b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a != b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 100 \n",
    "b = 120 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 == 120\n",
    "a == b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 != 120\n",
    "a != b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 > 120\n",
    "a > b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 < 120\n",
    "a < b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 <= 120\n",
    "a <= b "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 100 >= 120\n",
    "a >= b "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Logical Operators \n",
    "\n",
    "- An operator which checks two different conditions and then \n",
    "\n",
    "\n",
    "- AND \n",
    "- OR \n",
    "- NOT \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = 34\n",
    "e = 45 \n",
    "f = 56"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d == e "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d == f"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d == e and d == f"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n",
      "False\n",
      "False\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "# AND \n",
    "# c1 * c2 = ans \n",
    "# 1 * 1 = 1\n",
    "# 1 * 0 = 0 \n",
    "# 0 * 1 = 0 \n",
    "# 0 * 0 = 0 \n",
    "print( True and True ) \n",
    "print( False and True )\n",
    "print( True and False )\n",
    "print( False and False )\n",
    "\n",
    "d = 34\n",
    "e = 45 \n",
    "f = 56\n",
    "\n",
    "cond1 = (d > e)\n",
    "cond2 = (e < f)\n",
    "print(cond1 and cond2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n",
      "True\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "#OR \n",
    "#1 + 1 = 1\n",
    "#0 + 1 = 1\n",
    "#1 + 0 = 1\n",
    "#0 + 0 = 0\n",
    "\n",
    "print( True or True ) \n",
    "print( False or True )\n",
    "print( True or False )\n",
    "print( False or False )\n",
    "\n",
    "d = 34\n",
    "e = 45 \n",
    "f = 56\n",
    "\n",
    "cond1 = (d > e)\n",
    "cond2 = (e < f)\n",
    "print(cond1 or cond2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "# NOT \n",
    "print(not True)\n",
    "print(not False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chained Comp. Operators "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "d = 34\n",
    "e = 45 \n",
    "f = 56\n",
    "\n",
    "print(d < e < f)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Statements \n",
    "\n",
    "- IF ELSE  \n",
    "\n",
    "- Loops "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "saiPassedClassNine = True "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "saiPassedClassNine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Purchase Class 10th books\n"
     ]
    }
   ],
   "source": [
    "if saiPassedClassNine == True:\n",
    "    print(\"Purchase Class 10th books\")\n",
    "else:\n",
    "    print(\"Purchase Class 9th Note books\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "if __condition____ : \n",
    "    code block1\n",
    "    code block1\n",
    "    code block1\n",
    "else:\n",
    "    code block2\n",
    "    code block2\n",
    "    code block2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You are promoted to class 10\n"
     ]
    }
   ],
   "source": [
    "saiMarksInClass9 = 41\n",
    "\n",
    "if saiMarksInClass9 >= 41:\n",
    "    print(\"You are promoted to class 10\")\n",
    "elif saiMarksInClass9 >=35 and saiMarksInClass9 <= 40:\n",
    "    print(\"You will be considered for Grace marks\")\n",
    "elif saiMarksInClass9 >= 31 and saiMarksInClass9< 35:\n",
    "    print(\"Prents need to visit principal sir/ma'am\")\n",
    "else:\n",
    "    print(\"Sorry repeat class 9 again\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# How to get input from user ??\n",
    "\n",
    "input function => \n",
    "\n",
    "- input()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter something Shravani - Hey All\n"
     ]
    }
   ],
   "source": [
    "someText = input(\"Enter something Shravani - \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Hey All'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "someText"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter some Number = 4500\n"
     ]
    }
   ],
   "source": [
    "someNumber = int(input(\"Enter some Number = \"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4500"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "someNumber"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(someText)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(someNumber)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# LOOPS ??\n",
    "\n",
    "Loops are been used for doing some kinds of repetative tasks \n",
    "\n",
    "Loops are been used for iterating through a particular objectsin python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = [1,2,3,4,5,6,7,8,9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "list item -  1\n",
      "list item -  2\n",
      "list item -  3\n",
      "list item -  4\n",
      "list item -  5\n",
      "list item -  6\n",
      "list item -  7\n",
      "list item -  8\n",
      "list item -  9\n"
     ]
    }
   ],
   "source": [
    "for item in lst:\n",
    "    print(\"list item - \", item)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "for element in ObjectYouWantToItterate:\n",
    "    code block for the element\n",
    "    code blocl for the element\n",
    "    \n",
    "What all object you can iterate ?\n",
    "- List \n",
    "- String \n",
    "- Tuple \n",
    "- Dict\n",
    "- Set \n",
    "Where you are having collections"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "abc = \"HEY guys i hope that u all are understanding put up rating out of 5 for this lec.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'HEY guys i hope that u all are understanding put up rating out of 5 for this lec.'"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "abc "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "E\n",
      "Y\n",
      " \n",
      "g\n",
      "u\n",
      "y\n",
      "s\n",
      " \n",
      "i\n",
      " \n",
      "h\n",
      "o\n",
      "p\n",
      "e\n",
      " \n",
      "t\n",
      "h\n",
      "a\n",
      "t\n",
      " \n",
      "u\n",
      " \n",
      "a\n",
      "l\n",
      "l\n",
      " \n",
      "a\n",
      "r\n",
      "e\n",
      " \n",
      "u\n",
      "n\n",
      "d\n",
      "e\n",
      "r\n",
      "s\n",
      "t\n",
      "a\n",
      "n\n",
      "d\n",
      "i\n",
      "n\n",
      "g\n",
      " \n",
      "p\n",
      "u\n",
      "t\n",
      " \n",
      "u\n",
      "p\n",
      " \n",
      "r\n",
      "a\n",
      "t\n",
      "i\n",
      "n\n",
      "g\n",
      " \n",
      "o\n",
      "u\n",
      "t\n",
      " \n",
      "o\n",
      "f\n",
      " \n",
      "5\n",
      " \n",
      "f\n",
      "o\n",
      "r\n",
      " \n",
      "t\n",
      "h\n",
      "i\n",
      "s\n",
      " \n",
      "l\n",
      "e\n",
      "c\n",
      ".\n"
     ]
    }
   ],
   "source": [
    "for element in abc:\n",
    "    print(element)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Print all the even numbers in the range of 1- 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = [1,2,3,4,5,6,7,8,9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst = list(range(1,101))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "9 % 2 \n",
    "# % operator is actually known as moduloo operator,\n",
    "\n",
    "#which give the reminder of the division"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "4\n",
      "6\n",
      "8\n",
      "10\n",
      "12\n",
      "14\n",
      "16\n",
      "18\n",
      "20\n",
      "22\n",
      "24\n",
      "26\n",
      "28\n",
      "30\n",
      "32\n",
      "34\n",
      "36\n",
      "38\n",
      "40\n",
      "42\n",
      "44\n",
      "46\n",
      "48\n",
      "50\n",
      "52\n",
      "54\n",
      "56\n",
      "58\n",
      "60\n",
      "62\n",
      "64\n",
      "66\n",
      "68\n",
      "70\n",
      "72\n",
      "74\n",
      "76\n",
      "78\n",
      "80\n",
      "82\n",
      "84\n",
      "86\n",
      "88\n",
      "90\n",
      "92\n",
      "94\n",
      "96\n",
      "98\n",
      "100\n",
      "THis is the end of for Loop\n"
     ]
    }
   ],
   "source": [
    "for element in lst:\n",
    "    if element%2 == 0:\n",
    "        print(element)\n",
    "else:\n",
    "    print(\"THis is the end of for Loop\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# While Loops\n",
    "\n",
    "- When you dont have any measurable end for any repitative tasks "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Syntax - \n",
    "\n",
    "while condition :\n",
    "    codeBlock\n",
    "    codeBlock\n",
    "    codeBlock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "33000  You can remove your Seat belts\n",
      "32000  You can remove your Seat belts\n",
      "31000  You can remove your Seat belts\n",
      "30000  You can remove your Seat belts\n",
      "29000  You can remove your Seat belts\n",
      "28000  You can remove your Seat belts\n",
      "27000  You can remove your Seat belts\n",
      "26000  You can remove your Seat belts\n",
      "25000  You can remove your Seat belts\n",
      "24000  You can remove your Seat belts\n",
      "23000  You can remove your Seat belts\n",
      "22000  You can remove your Seat belts\n",
      "21000  You can remove your Seat belts\n",
      "20000  You can remove your Seat belts\n",
      "19000  You can remove your Seat belts\n",
      "18000  You can remove your Seat belts\n",
      "17000  You can remove your Seat belts\n",
      "16000  You can remove your Seat belts\n",
      "15000  You can remove your Seat belts\n",
      "14000  You can remove your Seat belts\n",
      "13000  You can remove your Seat belts\n",
      "12000  You can remove your Seat belts\n",
      "11000  You can remove your Seat belts\n",
      "10000  You can remove your Seat belts\n",
      "9000  You can remove your Seat belts\n",
      "8000  You can remove your Seat belts\n",
      "7000  You can remove your Seat belts\n",
      "6000  You can remove your Seat belts\n",
      "5000  You can remove your Seat belts\n",
      "4000  You can remove your Seat belts\n",
      "3000  You can remove your Seat belts\n",
      "2000  You can remove your Seat belts\n",
      "1000  Please Fasten your Seat belts\n"
     ]
    }
   ],
   "source": [
    "altitudeInSky = 33000\n",
    "\n",
    "while altitudeInSky > 1000:\n",
    "    print(altitudeInSky, \" You can remove your Seat belts\")\n",
    "    altitudeInSky = altitudeInSky - 1000\n",
    "else:\n",
    "    print(altitudeInSky, \" Please Fasten your Seat belts\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter your password sai\n",
      "Password accepted, you can goahead\n"
     ]
    }
   ],
   "source": [
    "password = \"\"\n",
    "while password != \"sai\":\n",
    "    password = input(\"Enter your password \")\n",
    "else:\n",
    "    print(\"Password accepted, you can goahead\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"LetsUpgrade\" != \"sai\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"sai\" != \"sai\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
